﻿using System;
using System.IO;
using Autodesk.Revit.DB;
using YArchitech.LIB;

namespace YJKDimensionModel.DetailIndex.Manager
{
	internal class Utility
	{
		public static string GetUserTempDirectory()
		{
			string environmentVariable = Environment.GetEnvironmentVariable("TEMP");
			DirectoryInfo directoryInfo = new DirectoryInfo(environmentVariable);
			return directoryInfo.FullName + "\\";
		}

		public static string GetFamilyFileName(Autodesk.Revit.DB.Document doc)
		{
			string versionNumber = doc.Application.VersionNumber;
			return Product.FamilyLocation + "\\" + versionNumber + "\\DetailIndex\\HY-IndexMark.rfa";
		}

		public static string GetFamilyFileName(Autodesk.Revit.DB.Document doc, DetailIndexType type)
		{
			string result = "";
			string versionNumber = doc.Application.VersionNumber;
			switch (type)
			{
			case DetailIndexType.NoRangeDirectIndex:
			case DetailIndexType.SingleSliceIndex:
			case DetailIndexType.MultiSliceIndex:
				result = Product.FamilyLocation + "\\" + versionNumber + "\\DetailIndex\\HY-IndexMark.rfa";
				break;
			case DetailIndexType.RangeDirectIndex:
				result = Product.FamilyLocation + "\\" + versionNumber + "\\DetailIndex\\HY-IndexMarkCircle.rfa";
				break;
			}
			return result;
		}

		public static void DeleteFile(string filename)
		{
			if (File.Exists(filename))
			{
				File.Delete(filename);
			}
		}
	}
}
